import axios from 'axios';

async function get(url, headers = {}) {
  const response = await axios.get(url, { headers });
  return response.data; // axios直接返回data
}

export async function fetchStudents() {
  const url = 'https://hongliang.co/node-api/users';
  const headers = {
    'Content-Type': 'application/json'
  };

  try {
    const students = await get(url, headers);
    return students.data.users
  } catch (error) {
    console.error('Error fetching students:', error);
    throw error;
  }
}
